import jieba


def context_jieba(data):
    seg = jieba.cut_for_search(data)
    l = []
    for word in seg:
        l.append(word)
    return l


def filter_word(data):
    return data not in ['谷', '帮', '客']


def append_words(data):
    """修订某些关键词"""
    if data == "传智播": data = "传智播客"
    if data == "院校": data = "院校帮"
    if data == "博学": data = "博学谷"
    return data


def extract_user_words(data):
    """传入数据 （用户ID，content）"""
    user_id = data[0]
    content = data[1]
    words = context_jieba(content)
    l = []

    for word in words:
        if filter_word(word):
            l.append(user_id + "_" + append_words(word))
    return l;
